<?php
	class hocsinhdb
	{
		public function Add($MaHocSinh ,$HoTen,$NgaySinh,$Phai,$DanToc,$DiaChi,$DienThoai,$GhiChu)
		{
			$sql = " INSERT INTO `tbl_hocsinh`(`MaHocSinh`, `HoTen`, `NgaySinh`, `Phai`, `DanToc`, `DiaChi`, `DienThoai`, `GhiChu`)
			VALUES ('$MaHocSinh' ,".dataservice::slashes($HoTen).",".dataservice::slashes($NgaySinh).",'$Phai',".dataservice::slashes($DanToc).",".dataservice::slashes($DiaChi).",".dataservice::slashes($DienThoai).",".dataservice::slashes($GhiChu).")";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Delete($MaHocSinh)
		{
			$sql = "DELETE FROM `tbl_hocsinh` WHERE MaHocSinh = '$MaHocSinh' ";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Update($MaHocSinh ,$HoTen,$NgaySinh,$Phai,$DanToc,$DiaChi,$DienThoai,$GhiChu)
		{
			$sql = "UPDATE `tbl_hocsinh`
			 SET 
			 	 HoTen = ".dataservice::slashes($HoTen).",
				 DiaChi = ".dataservice::slashes($DiaChi).",
				 DienThoai = ".dataservice::slashes($DienThoai).",
				 Phai = '$Phai',
				 NgaySinh =".dataservice::slashes($NgaySinh).",
				 DanToc = ".dataservice::slashes($DanToc).",
				 GhiChu = ".dataservice::slashes($GhiChu)."
			 WHERE MaHocSinh = '$MaHocSinh'"; 
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		
	
		public function GetList($MaHocSinh ,$HoTen,$NgaySinh,$Phai,$DanToc,$DiaChi,$DienThoai,$GhiChu)
		{
			$sql = " SELECT * FROM `tbl_hocsinh` WHERE 1 ";
			if($MaHocSinh!="")
				$sql .= " AND tbl_hocsinh.MaHocSinh = '$MaHocSinh' ";
			if($HoTen!="")
				$sql .= " AND tbl_hocsinh.HoTen = '$HoTen' ";
			if($NgaySinh!="")
				$sql .= " AND tbl_hocsinh.NgaySinh = '$NgaySinh' ";
			if($Phai!="")
				$sql .= " AND tbl_hocsinh.Phai = '$Phai' ";
			if($DanToc!="")
				$sql .= " AND tbl_hocsinh.DanToc = '$DanToc' ";
			if($DiaChi!="")
				$sql .= " AND tbl_hocsinh.DiaChi = '$DiaChi' ";
			if($DienThoai!="")
				$sql .= " AND tbl_hocsinh.DienThoai = '$DienThoai' ";
			if($GhiChu!="")
				$sql .= " AND tbl_hocsinh.GhiChu = '$GhiChu' ";
				
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		public function Find($MaHocSinh ,$HoTen,$NgaySinh,$Phai,$DanToc,$DiaChi,$DienThoai,$GhiChu)
		{
			$sql = " SELECT * FROM `tbl_hocsinh` WHERE 1 ";
			if($MaHocSinh!="")
				$sql .= " AND tbl_hocsinh.MaHocSinh LIKE '%$MaHocSinh%' ";
			
			if($HoTen!="")
				$sql .= " AND tbl_hocsinh.HoTen LIKE '%$HoTen%' ";
			if($NgaySinh!="")
				$sql .= " AND tbl_hocsinh.NgaySinh LIKE '%$NgaySinh%' ";
			if($Phai!="")
				$sql .= " AND tbl_hocsinh.Phai = '$Phai' ";
			if($DanToc!="")
				$sql .= " AND tbl_hocsinh.DanToc LIKE '%$DanToc%' ";
			if($DiaChi!="")
				$sql .= " AND tbl_hocsinh.DiaChi LIKE '%$DiaChi%' ";
			if($DienThoai!="")
				$sql .= " AND tbl_hocsinh.DienThoai LIKE '%$DienThoai%' ";
			if($GhiChu!="")
				$sql .= " AND GhiChu LIKE '%$GhiChu%' ";			
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		
	}
?>